home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
VS_804.ARJ
/
MISC.EXE
/
DICT2NG.PRG
< prev
next >
Wrap
Text File
|
1991-11-15
|
6KB
|
274 lines
* Filename......: Dict2Ng.Prg
*
* Author........: Vernon E. Six, Jr.
*
* Last Update...: Wed 10-02-1991 13:35:55
*
* Notice........: Copyright (c) 1991 by Vernon E. Six, Jr.
* All Rights Reserved World Wide
#include "FILEIO.CH"
#include "SETCURS.CH"
#include "SET.CH"
FUNCTION Dict2Ng(pc_FileName)
*****
* Prints a database dictionary listing to a Norton Guides DAT file
*****
LOCAL c_FileName
LOCAL n_Handle
LOCAL n_CurrRec := 0
VS_InitVern()
VS_NewScrn()
SET(_SET_DELETED,.T.)
*****
* Open the data dictionary files (create indexes if they don't exist!)
*****
BEGIN SEQUENCE
*══════════════════════════════════════════════════════════*
SELECT 0
IF .NOT. VS_Use("_DictHdr",.F.,"_DictHdr")
BREAK
ENDIF
IF .NOT. FILE("_DictHdr.Ntx")
IF .NOT. VS_ShowNtx("_DictHdr","DBF_NAME","C")
BREAK
ENDIF
ENDIF
dbClearIndex()
dbSetIndex("_DictHdr")
*══════════════════════════════════════════════════════════*
SELECT 0
IF .NOT. VS_Use("_DictFld",.F.,"_DictFld")
BREAK
ENDIF
IF .NOT. FILE("_DictFld.Ntx")
IF .NOT. VS_ShowNtx("_DictFld","DBF_NAME+FIELD_NMBR","C")
BREAK
ENDIF
ENDIF
IF .NOT. FILE("_DictFl2.Ntx")
IF .NOT. VS_ShowNtx("_DictFl2","DBF_NAME+FIELD_NAME","C")
BREAK
ENDIF
ENDIF
dbClearIndex()
dbSetIndex("_DictFld")
dbSetIndex("_DictFl2")
*══════════════════════════════════════════════════════════*
SELECT 0
IF .NOT. VS_Use("_DictNtx",.F.,"_DictNtx")
BREAK
ENDIF
IF .NOT. FILE("_DictNtx.Ntx")
IF .NOT. VS_ShowNtx("_DictNtx","DBF_NAME+ORDER","C")
BREAK
ENDIF
ENDIF
dbClearIndex()
dbSetIndex("_DictNtx")
*══════════════════════════════════════════════════════════*
*****
* Make an assumption if it isn't specified
*****
IF VALTYPE(pc_FileName) == "U"
pc_FileName = "DICT_RPT"
ENDIF
*****
* Open the .DAT file (since we are going to create it!)
*****
c_FileName = ALLTRIM(pc_FileName)+".DAT"
IF (n_Handle := FCREATE( c_FileName, 0 ) ) = F_ERROR
VS_TELL(3,0,PADC("Unable to create "+c_FileName))
BREAK
ELSE
VS_Write(n_Handle)
ENDIF
VS_GrabScr()
VS_Palette(2)
VS_NewScrn()
VS_Wind(8,13,16,66,"","")
SETCURSOR(SC_NONE)
@ 10,15 SAY PADC("Dict2Ng.Exe Wed 10-02-1991 13:40:27",50)
@ 12,15 SAY PADC("Writing Data File!",50)
@ 14,15 SAY REPLICATE("░",50)
_DICTHDR->( dbGoTop() )
DO WHILE .NOT. _DICTHDR->( EOF() )
n_CurrRec++
@ 14,15 SAY REPLICATE("█", VS_ScrlBar( n_CurrRec, 50, RECCOUNT() ))
*****
* Print the structure first
*****
PRT_STRU()
*****
* Then print the index keys
*****
PRT_NTX()
*****
* Next... please.
*****
_DICTHDR->( dbSkip() )
ENDDO
FCLOSE( n_Handle )
VS_PutScr()
dbCloseAll()
END SEQUENCE
RETURN(NIL)
*** EOF: Dict2Ng.Prg ********************************************************
FUNCTION PRT_STRU
*****
* Print the structure
*****
LOCAL c_Temp
VS_WriteLn( "'" + REPLICATE("─",70) )
VS_WriteLn( "!short: " + _DICTHDR->DBF_NAME + " " + _DICTHDR->DESC )
VS_WriteLn( "^B" + _DICTHDR->DBF_NAME + " " + _DICTHDR->DESC + "^B" )
VS_WriteLn( [] )
VS_WriteLn( [] )
c_Temp = "DataBase Structure"
VS_WriteLn( SPACE(VS_CENTER(c_Temp)) + "^U"+ c_Temp +"^U" )
VS_WriteLn( [] )
VS_WriteLn( "^B" + ;
SPACE(2) + "###" + ;
SPACE(2) + "Field Name" + ;
SPACE(2) + "Type" + ;
SPACE(2) + "Len" + ;
SPACE(2) + "Dec" + ;
SPACE(2) + "Description" )
VS_WriteLn( SPACE(2) + REPLICATE("─",74) + "^B" )
_DICTFLD->( dbSeek( _DICTHDR->DBF_NAME ) )
DO WHILE .NOT. _DICTFLD->( EOF() )
*****
* Have we skipped past this database?
*****
IF _DICTFLD->DBF_NAME <> _DICTHDR->DBF_NAME
EXIT
ENDIF
*****
* Print it!
*****
VS_WriteLn( SPACE(2) + _DICTFLD->FIELD_NMBR + ;
SPACE(2) + _DICTFLD->FIELD_NAME + ;
SPACE(4) + _DICTFLD->FIELD_TYPE + ;
SPACE(3) + STR(_DICTFLD->FIELD_LEN,3,0) + ;
SPACE(2) + STR(_DICTFLD->FIELD_DEC,3,0) + ;
SPACE(2) + _DICTFLD->DESC )
*****
* Next... please.
*****
_DICTFLD->(dbSkip())
ENDDO
RETURN(NIL)
*** EOF: PRT_STRU() *********************************************************
FUNCTION PRT_NTX
*****
* Print the index keys
*****
PRIVATE c_Temp
VS_WriteLn( [] )
VS_WriteLn( [] )
c_Temp = "Index Keys"
VS_WriteLn( SPACE(VS_CENTER(c_Temp)) + "^U"+ c_Temp +"^U" )
VS_WriteLn( [] )
VS_WriteLn( "^B" + ;
SPACE(2) + "##" + ;
SPACE(2) + "NTX Name" + ;
SPACE(2) + "Type" + ;
SPACE(2) + "Key" )
VS_WriteLn( SPACE(2) + REPLICATE("─",74) + "^B" )
_DICTNTX->( dbSeek( _DICTHDR->DBF_NAME ) )
DO WHILE .NOT. _DICTNTX->( EOF() )
*****
* Have we skipped past this database?
*****
IF _DICTNTX->DBF_NAME <> _DICTHDR->DBF_NAME
EXIT
ENDIF
*****
* Print it!
*****
VS_WriteLn( SPACE(2) + _DICTNTX->ORDER + ;
SPACE(2) + _DICTNTX->NTX_NAME + ;
SPACE(4) + _DICTNTX->TYPE + ;
SPACE(3) + SUBSTR(_DICTNTX->KEY,1,50) )
IF .NOT. EMPTY(SUBSTR(_DICTNTX->KEY,50,30))
VS_WriteLn( SPACE(30) + SUBSTR(_DICTNTX->KEY,50,30) )
ENDIF
*****
* Next... please.
*****
_DICTNTX->( dbSkip() )
ENDDO
RETURN(NIL)
*** EOF: PRT_NTX() **********************************************************